import { useMenuStore } from "@/store/menu";
import router from "@/router";
function checkPermission(el: Element, binding: DirectiveBinding) {
  const { value } = binding;
  const permissionInfo = useMenuStore().permissionInfo;
  // const permissionRoles = value;
  /* 判断当前页面对应的按钮（或者节点）是否可以显示 */
  const hasPermission = permissionInfo[router.currentRoute.value.name as string].includes(value);
  if (!hasPermission) {
    if (el.parentNode) {
      el.parentNode.removeChild(el);
    }
  }
}

export default {
  mounted(el: Element, binding: DirectiveBinding) {
    checkPermission(el, binding);
  }
  // update (el, binding) {
  //   checkPermission(el, binding);
  // }
};
